import React from 'react'
import Info from './UserInfo'
import Order from './UserOrder'
import Func from './UserFunc'

import { browserHistory } from 'react-router'
import { connectUser } from '../../container/user/connectUser'


class UserManage extends React.Component {
	constructor(props) {
		super(props)
		this.state = {
			show: false,
			showPic: false,
			accountData: null,
			accountPic: null,
			userName: null,
			userPhone: null,
		}
	}
	componentDidMount() {
		this.props.accountActions.showAccount();
		this.props.accountActions.showAccountPic();
		// alert('fsdf');
		this.setState({
			show: true,
			showPic: true,
		})
	}
	componentWillReceiveProps(nextProps) {
		if (nextProps.account.showed == "success" && this.state.show == true) {
			this.setState({
				accountData: nextProps.account.accountData,
				show: false,
				userName: nextProps.account.accountData.userName,
				userPhone: nextProps.account.accountData.userPhone,
			})
		}
		if (nextProps.account.picshowed == "success" && this.state.showPic == true) {
			this.setState({
				showPic: false,
				accountPic: nextProps.account.accountPic,
			})
		}
	}
	render() {
		const { storeId } = this.props.params;
		const {accountData,accountPic,userPhone,userName} = this.state;
		return (
            <div>
               <Info userName={userName} userPhone={userPhone} accountPic={accountPic}/>
               <Order storeId={storeId} />
               <Func storeId={storeId} />
            </div>
		);
	}
}
export default connectUser(UserManage)
